package tech.aistar.mapper;

import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import tech.aistar.entity.authordis.NoteAuthor;

/**
 * Created by Dell on 2019/10/6.
 */
public interface EditNotesMapper {

    //查询编写游记的作者
    @Select("select * from note_author where user_id = #{value}")
    NoteAuthor findNoteAuthor(Integer user_id);

    //插入数据
//    @Insert("insert into notes(autuor_id,content,title,publish_time) values(#{autuor_id},#{content},#{title},#{publish_time})")
//    void saveNotes(@Param("autuor_id") Integer autuor_id, @Param("content") String content, @Param("title") String title,@Param("publish_time")String publish_time);

    @Insert("insert into notes(autuor_id,title,note_type,publish_time,front_img) values(#{autuor_id},#{title},#{note_type},#{publish_time},#{front_img})")
    void saveNotes(@Param("autuor_id") Integer autuor_id, @Param("title") String title,@Param("note_type") Integer note_type ,@Param("publish_time") String publish_time,@Param("front_img") String front_img);

    //查找文章id
    @Select("select id from notes where title = #{title} and publish_time = #{publish_time}")
    Integer findNotesId(@Param("title") String title, @Param("publish_time") String publish_time);


    //插入文章内容
    @Insert("insert into notes_info(notes_id,page_id,photo,content) values(#{notes_id},#{page_id},#{photo},#{content})")
    void saveNotesInfo(@Param("notes_id") Integer notes_id, @Param("page_id") Integer page_id, @Param("photo") String photo, @Param("content") String content);
}
